import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

//Saves the board object passed into the board.ser  file
public class SerializeBoard{
	public static void serialize(Board b){
		try
		      {
		         FileOutputStream fileOut = new FileOutputStream("board.ser");
		         ObjectOutputStream out = new ObjectOutputStream(fileOut);
		         out.writeObject(b);
		         out.close();
		         fileOut.close();
		      }catch(IOException i)
		      {
		          i.printStackTrace();
		      }
			
	}
	
//Deserializes the board.ser file and returns a board object	
	public static Board deserialize(){
		Board b = null;
		 try
	      {
	         FileInputStream fileIn = new FileInputStream("board.ser");
	         ObjectInputStream in = new ObjectInputStream(fileIn);
	         b = (Board) in.readObject();
	         in.close();
	         fileIn.close();
	         
	      }catch(IOException i)
	      {
	         i.printStackTrace();
	         //return;
	      }catch(ClassNotFoundException c)
	      {
	    	  System.out.println("Class not found!!!");
	          c.printStackTrace();
	          //return;
	       }
		 return b;
	 }
}